import Vue from "vue";
import VueX from "vuex";
import createPersistedState from 'vuex-persistedstate';

Vue.use(VueX);

const store = new VueX.Store({
    plugins: [
        createPersistedState({
          storage: window.sessionStorage
        })
    ],
    state: {
        roomNumber:'',
        areaName:'',
        communityName:'',
        isRegistered:false,
        isLogin:false,
        registerTenant:{},
        loginTenant:{},
    },
    getters:{
        getRoomNumber(state){
            return state.roomNumber;
        },
        getAreaName(state){
            return state.areaName;
        },
        getCommunityName(state){
            return state.communityName;
        },
        getIsRegistered(state){
            return state.isRegistered;
        },
        getIsLogin(state){
            return state.isLogin;
        },
        getRegisterTenant(state){
            return state.registerTenant;
        },
        getLoginTenant(state){
            return state.loginTenant;
        }
    },
    mutations:{
        setRoomNumber(state,roomNumber){
            state.roomNumber = roomNumber;
        },
        setAreaName(state,areaName){
            state.areaName = areaName;
        },
        setCommunityName(state,communityName){
            state.communityName = communityName;
        },
        setIsRegistered(state,isRegistered){
            state.isRegistered = isRegistered;
        },
        setIsLogin(state,isLogin){
            state.isLogin = isLogin;
        },
        setRegisterTenant(state,registerTenant){
            state.registerTenant = registerTenant;
        },
        setLoginTenant(state,loginTenant){
            state.loginTenant = loginTenant;
        }
    },
    actions:{
        setRoomNumber({commit},roomNumber){
            commit('setRoomNumber',roomNumber);
        },
        setAreaName({commit},areaName){
            commit('setAreaName',areaName);
        },
        setCommunityName({commit},communityName){
            commit('setCommunityName',communityName);
        },
        setIsRegistered({commit},isRegistered){
            commit('setIsRegistered',isRegistered);
        },
        setIsLogin({commit},isLogin){
            commit('setIsLogin',isLogin);
        },
        setRegisterTenant({commit},registerTenant){
            commit('setRegisterTenant',registerTenant);
        },
        setLoginTenant({commit},loginTenant){
            commit('setLoginTenant',loginTenant);
        }
    }
})
export default store;